﻿<UserControl x:Class="DaxStudio.UI.Views.ucSpinner"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="20" d:DesignWidth="20"
             >
    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
        <SolidColorBrush x:Key="SpinnerColorBrush" Color="Black"></SolidColorBrush>
        <Storyboard x:Key="Rotation">

            <DoubleAnimation Storyboard.TargetName="rotateTransform"
                       Storyboard.TargetProperty="Angle"
                       From="0" To="360" Duration="00:00:01"
                       RepeatBehavior="Forever"/>
        </Storyboard>
        

    </UserControl.Resources>
    <Grid>
        <Grid.Resources>
            <Style x:Key="SpinnerStyle" TargetType="Label">
                <Style.Setters>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate>
                                
                                <Grid Name="LayoutRoot" RenderTransformOrigin="0.5,0.5" Background="{TemplateBinding Background}">
                                    
                                    <Grid.RenderTransform>
                                        <TransformGroup>
                                            <RotateTransform x:Name="rotateTransform"/>
                                        </TransformGroup>
                                    </Grid.RenderTransform>
                                    <Ellipse Fill="{TemplateBinding Foreground }">
                                        <!--<Ellipse Fill="{DynamicResource SpinnerColorBrush}">-->

                                        <Ellipse.OpacityMask>
                                            <ImageBrush ImageSource="SpinnerMask.png" Stretch="None"/>
                                        </Ellipse.OpacityMask>
                                    </Ellipse>
                                    <Grid.OpacityMask>
                                        <RadialGradientBrush>
                                            <GradientStop Color="Black" Offset="0.96"/>
                                            <GradientStop Color="Transparent" Offset="0.6"/>
                                        </RadialGradientBrush>
                                    </Grid.OpacityMask>
                                    <Grid.Triggers>
                                        <EventTrigger RoutedEvent="Window.Loaded">
                                            <BeginStoryboard>
                                                <Storyboard>
                                                    <DoubleAnimation Storyboard.TargetName="rotateTransform"
                                            Storyboard.TargetProperty="Angle"
                                            From="0" To="360" Duration="00:00:01"
                                            RepeatBehavior="Forever"/>
                                                </Storyboard>
                                            </BeginStoryboard>
                                        </EventTrigger>
                                    </Grid.Triggers>
                                </Grid>
                                    
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style.Setters>
            </Style>

            <Style x:Key="SpinnerStyle2" TargetType="TextBox">
                <Style.Setters>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <Grid Name="LayoutRoot" RenderTransformOrigin="0.5,0.5" Background="{TemplateBinding Background}">

                                        <Grid.RenderTransform>
                                            <TransformGroup>
                                                <RotateTransform x:Name="rotateTransform"/>
                                            </TransformGroup>
                                        </Grid.RenderTransform>
                                        <Ellipse Fill="{TemplateBinding Foreground }">
                                            <!--<Ellipse Fill="{DynamicResource SpinnerColorBrush}">-->

                                            <Ellipse.OpacityMask>
                                                <ImageBrush ImageSource="SpinnerMask.png" Stretch="None"/>
                                            </Ellipse.OpacityMask>
                                        </Ellipse>
                                        <Grid.OpacityMask>
                                            <RadialGradientBrush>
                                                <GradientStop Color="Black" Offset="0.96"/>
                                                <GradientStop Color="Transparent" Offset="0.6"/>
                                            </RadialGradientBrush>
                                        </Grid.OpacityMask>
                                        <Grid.Triggers>
                                            <EventTrigger RoutedEvent="Window.Loaded">
                                                <BeginStoryboard>
                                                    <Storyboard>
                                                        <DoubleAnimation Storyboard.TargetName="rotateTransform"
                                            Storyboard.TargetProperty="Angle"
                                            From="0" To="360" Duration="00:00:01"
                                            RepeatBehavior="Forever"/>
                                                    </Storyboard>
                                                </BeginStoryboard>
                                            </EventTrigger>
                                        </Grid.Triggers>
                                    </Grid>
                                    <TextBlock Foreground="{TemplateBinding Foreground}" Text="{}" />
                                </StackPanel>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style.Setters>
            </Style>
        </Grid.Resources>
        <!--<Label Style="{StaticResource SpinnerStyle}" Foreground="{Binding Foreground,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" ></Label>-->
        <TextBox Style="{StaticResource SpinnerStyle2}" Foreground="Red" ></TextBox>
    </Grid>
</UserControl>
